package com.hxd.otc.module.coin_deal.adapter;

import android.text.TextUtils;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.hxd.otc.R;
import com.hxd.otc.module.coin_deal.bean.CoinDealRecoderBean;
import com.hxd.otc.utils.StringUtil;
import com.hxd.otc.utils.UIUtils;

/**
 * 作  者 :  zjl
 * 时  间 :  2018/7/10 10:22
 * 描  述 :  ${TODO}
 */
public class CoinDealRecoderAdapter extends BaseQuickAdapter<CoinDealRecoderBean.DataBean, BaseViewHolder> {

    public CoinDealRecoderAdapter() {
        super(R.layout.adapter_coin_deal_recoder, null);
    }

    @Override
    protected void convert(BaseViewHolder helper, CoinDealRecoderBean.DataBean item) {
        helper.setText(R.id.tv_order_number, UIUtils.getContext().getString(R.string.coin_number, item.bbNo));
        helper.setText(R.id.tv_name, item.nickName);

        if (TextUtils.isEmpty(item.transPair)) {
            helper.setText(R.id.tv_money, UIUtils.getContext().getString(R.string.deal_account, StringUtil.format8Number(item.totalPrice), UIUtils.getContext().getString(R.string.aec)));
            helper.setText(R.id.tv_deal_number, UIUtils.getContext().getString(R.string.deal_account, StringUtil.format4Number(item.transAmount), UIUtils.getContext().getString(R.string.msc)));
            helper.setText(R.id.tv_sale_type, UIUtils.getContext().getString(item.type == 0 ? R.string.coin_sale : R.string.coin_buy, UIUtils.getContext().getString(R.string.msc)));
        } else {
            String[] splitstr = item.transPair.split("/");
            helper.setText(R.id.tv_deal_number, UIUtils.getContext().getString(R.string.deal_account, StringUtil.format4Number(item.transAmount), splitstr[0]));
            helper.setText(R.id.tv_sale_type, UIUtils.getContext().getString(item.type == 0 ? R.string.coin_sale : R.string.coin_buy,  splitstr[0]));
            helper.setText(R.id.tv_money, UIUtils.getContext().getString(R.string.deal_account, StringUtil.format8Number(item.totalPrice),splitstr[1]));
        }

        helper.setText(R.id.tv_time, item.createTime);

    }
}
